package com.lei;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/**
 * @author: leiGer
 * @Date: 2022/01/15
 * @Time: 16:35
 */
//模拟单机redis
public class RedisUtils {
    private Logger logger = LoggerFactory.getLogger(RedisUtils.class);
    private Map<String,String> map =  new ConcurrentHashMap<>();
    public String get(String key){
        logger.info("redis获取的数据key：{}",key);
        return map.get(key);
    }
    public void set(String key,String val){
        logger.info("redis写入数据key：{},val:{}",key,val);
         map.put(key,val);
    }
    public void set(String key, String value, long timeout, TimeUnit timeUnit) {
        logger.info("Redis写入数据 key：{} val：{} timeout：{} timeUnit：{}", key, value, timeout, timeUnit.toString());
        map.put(key, value);
    }

    public void del(String key) {
        logger.info("Redis删除数据 key：{}", key);
        map.remove(key);
    }


}
